<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<%
			response.setHeader("Cache-Control", "no-store");
			response.setDateHeader("Expires", 0);
			response.setHeader("Pragma", "no-cache");
		%>
<title>恒拓运价魔方</title>
		<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
		<link href="<%=request.getContextPath() %>/fare/lib/css/index.css" rel="stylesheet" type="text/css" />
		<script src="<%=request.getContextPath() %>/fare/lib/jquery/jquery-1.6.4.min.js" type="text/javascript"></script>    
		<script src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script> 
		<script src="<%=request.getContextPath() %>/fare/indexdata.js" type="text/javascript"></script>
		<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/json2.js"></script>
		<script type="text/javascript">
			var tab = null;
			var accordion = null;
			
			function getTreeList(data){
				var list = {
					data: data,
					checkbox: false,
					slide: false,
					nodeWidth: 120,
					attribute: ['nodename', 'url'],
					onSelect: function (node){
						if (!node.data.url) return;
						var tabid = $(node.target).attr("tabid");
						if (!tabid)
						{
							tabid = new Date().getTime();
							$(node.target).attr("tabid", tabid)
						} 
						f_addTab(tabid, node.data.text, node.data.url);
					}
				}
				return list;
			}
			
			$(function ()
			{
				//布局
				$("#layout1").ligerLayout({ leftWidth: 190, height: '100%',heightDiff:-34,space:4, onHeightChanged: f_heightChanged });

				var height = $(".l-layout-center").height();

				//Tab
				$("#framecenter").ligerTab({ height: height });

				//面板
				var panel = $("#accordion1");
				/* var count = Object.keys(_menus).length; */
				/*
				下面方法不支持IE , revise by spring.hua
				 var array = Object.keys(_menus);
				for(var i in array){
					var title = _menus[array[i]][0];
					panel.append('<div title="'+title.menuname+'" class="l-scroll"><ul id="'+title.menuid+'" style="margin-top:3px;"></div>')
					var count = title.menus.length;
					var element = "[";
					for(var i = 0; i < count; i++){
						if(count != 1 & i != count-1){
							element +='{"text":"'+title.menus[i].menuname+'","url":"'+title.menus[i].url+'"}';
							element +=",";
						}else{
							element +='{"text":"'+title.menus[i].menuname+'","url":"'+title.menus[i].url+'"}';
						}
					}
					element += "]";
					element = JSON.parse(element);
					$("#"+title.menuid).ligerTree(getTreeList(element));
				}
				*/
				
				var urls="<%=request.getContextPath() %>"+"/loginPackage/loginAction!toMenuTree.action";
				 $.ajax({
						url:urls,
						type : "POST",
						cache : false, 
						async : false,
					    dataType:'html',
					    success:function(data){
					   	var obj = eval('(' + data + ')');
					   		$.each( obj, function(idx, e){
					   			$.each( e.head, function(id, ex){
					   			    panel.append('<div title="'+ex.menuname+'" class="l-scroll"><ul id="'+ex.menuid+'" style="margin-top:3px;"></div>');
					   				var element = "[";
					   				var count =ex.menus.length;
					   				$.each( ex.menus, function(i, menu){
					   					if(count != 1 & i != count-1){
											element +='{"text":"'+menu.menuname+'","url":"'+menu.url+'"}';
											element +=",";
										}else{
											element +='{"text":"'+menu.menuname+'","url":"'+menu.url+'"}';
										}
					   					 
					   				});
					   				element += "]";
									///element = JSON.parse(element);
									element = jQuery.parseJSON(element);
									$("#"+ex.menuid).ligerTree(getTreeList(element));
					   				
					   			});
					   		});
					    },
					    error:function(){ 
					    	alert("请先登录");
					    },
				 });
				 
				/* for (var name in _menus){
					 var title = _menus[name][0];
					 panel.append('<div title="'+title.menuname+'" class="l-scroll"><ul id="'+title.menuid+'" style="margin-top:3px;"></div>')
						var count = title.menus.length;
						var element = "[";
						for(var i = 0; i < count; i++){
							if(count != 1 & i != count-1){
								element +='{"text":"'+title.menus[i].menuname+'","url":"'+title.menus[i].url+'"}';
								element +=",";
							}else{
								element +='{"text":"'+title.menus[i].menuname+'","url":"'+title.menus[i].url+'"}';
							}
						}
						element += "]";
						///element = JSON.parse(element);
						element = jQuery.parseJSON(element);
						$("#"+title.menuid).ligerTree(getTreeList(element));
				} */
				
				
				
				
				
				
				
				
				panel.ligerAccordion({ height: height - 24, speed: null });
				
				tab = $("#framecenter").ligerGetTabManager();
				accordion = $("#accordion1").ligerGetAccordionManager();
				$("#index").ligerGetTreeManager();
				$("#search").ligerGetTreeManager();
				$("#analysis").ligerGetTreeManager();
				$("#grab").ligerGetTreeManager();
				$("#system").ligerGetTreeManager();
				$("#pageloading").hide();

			});
			function f_heightChanged(options)
			{
				if (tab)
					tab.addHeight(options.diff);
				if (accordion && options.middleHeight - 24 > 0)
					accordion.setHeight(options.middleHeight - 24);
			}
			function f_addTab(tabid,text, url)
			{ 
				url = url.indexOf("/")==0 ? '<%=request.getContextPath() %>'+url : '<%=request.getContextPath() %>/'+url;
				tab.addTabItem({ tabid : tabid,text: text, url: url });
			}   
			function f_closeTab(tabid)
			{ 
				if(tabid)
					tab.removeTabItem(tabid);
			}   
		</script>
	</head>
	
	<body style="padding:0px;background:#EAEEF5;">  
	<div id="pageloading"></div>  
	<div id="topmenu" class="l-topmenu">
		<div class="l-topmenu-logo">
			<div class="hd-logo">&nbsp;</div>
			<div class="l-topmenu-welcome">
				<div class="admintu">
				<ul class="uld">
					<li>
						<span class="rentuwz" id="current_realname">${user.userName }</span>
					</li>
					
					<li class="shuxian">&nbsp;</li>
					<!-- <li class="gnwz"><a href="#" id="function_menu">功能菜单</a></li> -->
					<li class="shuxian">&nbsp;</li>
					<li class="zxwz" id="zx_btn"><a href="<%=request.getContextPath()%>/loginAction!logout.action">注销</a></li>
					
				</ul>
				</div>
			</div>
		</div>
	</div>
	<div id="layout1" style="width:99.2%; margin:0 auto; margin-top:4px; "> 
		<div position="left"  title="恒拓运价魔方" id="accordion1"> 
			<!-- <div title="首页" class="l-scroll">
				<ul id="index" style="margin-top:3px;">
			</div>
			<div title="运价查询" class="l-scroll">
				<ul id="search" style="margin-top:3px;">
			</div>
			<div title="运价分析" class="l-scroll">
				<ul id="analysis" style="margin-top:3px;">
			</div>
			<div title="抓取管理">
				<ul id="grab" style="margin-top:3px;">
			</div>
			<div title="系统管理">
				<ul id="system" style="margin-top:3px;">
			</div> -->
		</div>
		<div position="center" id="framecenter"> 
			<div tabid="home" title="首页" style="height:300px" >
				<iframe frameborder="0" name="home" id="home" src="<%=request.getContextPath() %>/fare/home.jsp"></iframe>
			</div> 
		</div> 	
	</div>
	<div  style="height:32px; line-height:32px; text-align:center;">
		Copyright © 2013-2014 www.foreveross.com
	</div>
	<div style="display:none"></div>
	</body>
</html>